package zero.boot.freemarkerdemo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import org.springframework.web.servlet.view.freemarker.FreeMarkerView;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;

@SpringBootApplication
@EnableAspectJAutoProxy
@ComponentScan(basePackages = {"zero.boot.freemarkerdemo", "zero.prjoect.advice"})
//@EnableWebMvc
public class FreemarkerDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(FreemarkerDemoApplication.class, args);
    }


    @Bean
    public FreeMarkerConfigurer viewConfigurer() {
        FreeMarkerConfigurer resolver = new FreeMarkerConfigurer();
        resolver.setTemplateLoaderPaths("/WEB-INF/pages");
        return resolver;
    }

    @Bean
    public FreeMarkerViewResolver viewResolver() {
        FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
        resolver.setViewClass(FreeMarkerView.class);
        resolver.setContentType("text/html; charset=utf-8");
        resolver.setCache(true);
        return resolver;
    }
}
